

'''
    this scripts dumps a pickle file with
    all codons' and aminos' names
'''

from codon_entropy import readfile

filename='escherichia.txt'
#filename='smallC.txt'

all_amino_lists, all_codon_lists= readfile(filename)


all_aminos=[]
for v in all_amino_lists:
    all_aminos+=v

all_codons=[]
for v in all_codon_lists:
    all_codons+=v


assert len(all_codons)==len(all_aminos)    

# for each amino, the possible codons

all_aminos_net={}
for index in range(len(all_aminos)):
    a=all_aminos[index]
    if a not in all_aminos_net:
        all_aminos_net[a]=[]
    all_aminos_net[a].append(all_codons[index])


for a in all_aminos_net:
    all_aminos_net[a]=list(set(all_aminos_net[a]))


print 'amino-codon possibilities'
print all_aminos_net
all_codons=list(set(all_codons))

print 'all_codons', len(all_codons)
print 'all_aminos', len(all_aminos_net)

import pickle
pickle.dump((all_codons, all_aminos_net), \
            open('all_codons_and_aminos.pkl', 'w'))
